<?php
# 引入数据库操作
require_once '../../include/common.inc.php';

# 获得分页数
$page = empty($_GET['page']) ? 1 :$_GET['page'];
$uid = $_GET['uid'] ;
# 总记录数
$num = $db->num_rows($db->query("select * from chat_gold_log where  type=1  and uid = $uid  order by dateline desc  "));

if(($num/5) <= 1 ){
    $page = 1;
}


# 差出分页数据
if($page == 1){
	$info = $db->query("select * from chat_gold_log where type=1 and uid = $uid  order by dateline desc  limit ".($page-1).",5");
}else{
	$info = $db->query("select * from chat_gold_log where type=1 and uid = $uid  order by dateline desc  limit  ".(($page-1)*5).",5");
}

$newinfo = [];
while($row=$db->fetch_row($info)){
    $row['dateline'] = date('Y-m-d H:i:s',$row['dateline']);
    $newinfo[]= $row;
}




# 转成JSON - 注意,JS的数组KEY只能是数字
$array = array(
	0 => $page, //当前分页数
	1 => $newinfo, //分页结果
	2 => $num   //总记录数
);
$array = json_encode($array);
echo $array;
?>
